//
//  CZHeadView.swift
//  GZWeibo666
//
//  Created by eshine_33 on 16/5/25.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CZHeadView: UIView {

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        parperUI()
    }
    
    /// 准备UI
    func parperUI() {
//        let label:UILabel?
//        label = UILabel()
//        label?.backgroundColor = UIColor.redColor()
//        label?.text = "测试"
//        label?.sizeToFit()
//        addSubview(label!)
        
        
        //topView 容器View
        let contentView:UIView?
        contentView = UIView()
        contentView?.backgroundColor = UIColor(white: 0.7, alpha: 0.9)
        contentView!.frame = CGRectMake(0, 0, UIScreen.width(), 150)
        
        // 头像imageView
        let iconView:UIImageView?
        iconView = UIImageView()
        iconView?.backgroundColor = UIColor.blueColor()
//        iconView?.image = UIImage(named: "avatar")
//        iconView!.ff_AlignInner(type: ff_AlignType.TopLeft, referView: contentView!, size: CGSize(width: UIScreen.width(), height: 60))
        iconView?.frame = CGRectMake(30, 10, 80, 80)
        iconView?.layer.cornerRadius = 40
        iconView?.layer.masksToBounds = true
        
        
        // 显示用户的头像
        if let avatar_large = CZUserAccount.loadUserAccount()?.avatar_large {
            iconView!.sd_setImageWithURL(NSURL(string: avatar_large), placeholderImage: UIImage(named: "avatar_default_big"))
        }
        
        
        //信息Label
        let countNameLabel:UILabel?
        countNameLabel = UILabel()
        countNameLabel?.text = CZUserAccount.loadUserAccount()?.screen_name ?? "weiboName"
//        countNameLabel?.backgroundColor = UIColor.redColor()
        countNameLabel?.frame = CGRectMake(130, 30, 0, 0)
        countNameLabel?.sizeToFit()
        
        contentView?.addSubview(countNameLabel!)
        
        //简介Label
        let messageLabel:UILabel?
        messageLabel = UILabel()
        messageLabel?.textColor = UIColor(white: 0.8, alpha: 1.0)
        messageLabel?.font = UIFont.systemFontOfSize(12)
        messageLabel?.text = "简介:暂无信息"
//        messageLabel?.backgroundColor = UIColor.redColor()
        messageLabel?.frame = CGRectMake(130, 60, 0, 0)
        messageLabel?.sizeToFit()
        
        contentView?.addSubview(messageLabel!)
        
        //topView的底部view
        let bottomview = UIView()
         bottomview.frame = CGRectMake(0, 100 , UIScreen.width(), 44)
         bottomview.backgroundColor = UIColor.whiteColor()
        
        // 关注  粉丝  赞
        let mesLaebl:UILabel?
        mesLaebl = UILabel()
        mesLaebl?.text = "关注 10"
        
        mesLaebl?.frame = CGRectMake(40, 12, 0, 0)
        mesLaebl?.sizeToFit()
        bottomview.addSubview(mesLaebl!)
        
        let mesLaebl2:UILabel?
        mesLaebl2 = UILabel()
        mesLaebl2?.text = "粉丝 8"
        
        mesLaebl2?.frame = CGRectMake(170, 12, 0, 0)
        mesLaebl2?.sizeToFit()
        bottomview.addSubview(mesLaebl2!)
        
        let mesLaebl3:UILabel?
        mesLaebl3 = UILabel()
        mesLaebl3?.text = "赞 20"
        
        mesLaebl3?.frame = CGRectMake(300, 12, 0, 0)
        mesLaebl3?.sizeToFit()
        bottomview.addSubview(mesLaebl3!)
        
        
        // 添加iconView到容器View中
        contentView?.addSubview(iconView!)
        contentView?.addSubview(bottomview)
        
        //把容器view
        addSubview(contentView!)
    }
    
    
    
}
